<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>父传子</title>
</head>
<body>

<!--
  props属性值类型：
   字符串String
   数值Number
   布尔值Boolean
   数组Array
   对象Object
-->

<div id="app">
  <menu-item></menu-item>
  <menu-item :p-num="pnum"></menu-item>
</div>

<script src="../lib/vue.js"></script>
<script>
Vue.component('menu-item', {
  props: {
    pNum: {
      type: Number,
      default: 12,
      validator: function (value) {
        return value > 10
      }
    }
  },
  template: `
    <div>
      <div>{{typeof pNum}} : {{pNum}}</div>
    </div>`
})

  let vm = new Vue({
    el: '#app',
    data: {
      pnum: 18,
    }
  })
</script>

</body>
</html>